﻿
using Cysharp.Threading.Tasks;
using YooAsset;

namespace Client.Base
{
    public class FsmDownloadPackageOver : PatchState
    {
        public FsmDownloadPackageOver(PatchProcess procedure) : base(procedure)
        {
        }

        public override async void OnEnter()
        {
            this.Log("[Patch] FsmDownloadPackageOver.");
            foreach (var pk in YAPackageInfo.Setting.packages)
            {
                if (!string.IsNullOrEmpty(pk.packageName))
                {
                    var package = YooAssets.GetPackage(pk.packageName);
                    var operation = package.ClearCacheFilesAsync(EFileClearMode.ClearUnusedBundleFiles);
                    await operation.ToUniTask();
                }
            }
            Process.TryTransition<FsmStartGame>();
        }
    }
}

